import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import discover from '../views/discover'
import order from '../views/order'
// @ 表示的是src文件夹
import profile from '@/views/profile' 
import hasRouter from '@/views/hasRouter'
import coin from '@/views/coin'
// use 使用vue的插件的方法
Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/', // 自己配置的页面跳转地址 '/' 表示默认渲染的页面的地址 必须要配置的项
  //   name: 'Home', // 给当前路由对象配置一个名字 可以不配置
  //   component: Home // 指明当前路由对象要跳转到的组件
  // },
  // {
  //   path: '/discover',
  //   name: "discover",
  //   component: discover
  // },
  // {
  //   path: '/profile',
  //   name: "profile",
  //   component: profile
  // },
  // {
  //   path: '/order',
  //   name: "order",
  //   component: order
  // }

  // 定义有router-view的组件
  {
    path: '/',
    name: 'hasRouter',
    component: hasRouter,
    // 路由重定向
    redirect: '/home',
    // 路由嵌套
    children: [
      {
        path: 'home', 
        name: 'Home',
        component: Home
      },
      {
        path: 'discover',
        name: "discover",
        component: discover
      },
      {
        path: 'profile',
        name: "profile",
        component: profile
      },
      {
        path: 'order',
        name: "order",
        component: order
      }
    ]
  },{
    path: '/coin',
    name: "coin",
    component: coin
  }
]

const router = new VueRouter({
  routes: routes
})

export default router
